
''' <summary>
''' Class that adds a student to a class and creates a new class member record.
''' This class is sealed, ie it is not availbale outside this assembly.
''' Clients should use the StudentClassManagerFactory to get instances of this 
''' class.  This is to encapsulate the logic of adding students to classes
''' </summary>
''' <remarks></remarks>
Class StudentClassManager
    Implements IStudentClassManager

    Private _candidateCodeGenFactory As CandidateCodeGeneratorFactory

    ReadOnly Property CandidateCodeGenFactory As CandidateCodeGeneratorFactory
        Get
            If (_candidateCodeGenFactory Is Nothing) Then
                _candidateCodeGenFactory = New CandidateCodeGeneratorFactory()
            End If
            Return _candidateCodeGenFactory
        End Get

    End Property



    Public Function addStudentToClass(ByVal student As Student, _
                                 ByVal pclass As PeriodClass) As ClassMember Implements _
                                        IStudentClassManager.addStudentToClass

        Dim classmember As ClassMember = ClassMemberFactory.Create(student, pclass)
        Dim candidateCodeGenerator As ICandidateCodeGenerator = Me.CandidateCodeGenFactory.getCandidateCodeGenerator(pclass, student)
        classmember.CandidateCode = candidateCodeGenerator.generateCandidateCode
        pclass.AddMember(classmember)
        Return classmember

    End Function

End Class
